﻿
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');


FantastPlatform.UI.ElementImplementForm = function (config) {
    Ext.apply(this, config);

    var statusStore = new Ext.data.SimpleStore({
        fields: ['Name', 'Value'],
        data: [['未开始执行', '未开始执行'], ['正在执行中', '正在执行中'], ['执行完成', '执行完成']]
    });
    var statusComboBox = new Ext.form.ComboBox({
        fieldLabel: '执行状态',
        name: 'StatusInfo',
        hiddenName: 'StatusInfo',
        store: statusStore,
        displayField: 'Name',
        mode: 'local',
        valueField: 'Value',
        allowBlank: false,
        editable: false,
        triggerAction: 'all',
        emptyText: '执行状态',
        readOnly: true,
        anchor: '90%'
    });
    this.items = [{
        layout: 'column',
        border: false,
        labelSeparator: '：',
        items: [{
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '参与部门',
                name: 'Organization',
                allowBlank: false,
                blankText: " 名称不能为空",
                anchor: '90%'
            })]
        }, {
            columnWidth: 1,
            border: false,
            layout: 'form',
            items: [new Ext.form.TextField({
                fieldLabel: '出动人数',
                name: 'PersonNumber',
                allowBlank: false,
                blankText: " 详情不能为空",
                anchor: '90%'
            })]
        },
//                {
//                    columnWidth: .4,
//                    border: false,
//                    layout: 'form',
//                    items: [new Ext.form.TextField({
//                        fieldLabel: '状态',
//                        name: 'StatusInfo',
//                        allowBlank: false,
//                        width: 80,
//                        anchor: '80%',
//                        blankText: " 梯队数量不能为空"
//                    })]
//                },
                {
                    columnWidth: .4,
                    border: false,
                    layout: 'form',
                    items: [statusComboBox]
                }, {
                    columnWidth: .6,
                    border: false,
                    layout: 'form',
                    items: [new FantastPlatform.UI.DateTimeField({
                        fieldLabel: '开始时间',
                        allowBlank: false,
                        name: 'StartTime',
                        timeFormat: 'H:i',
                        anchor: '80%',
                        width: 180,
                        dateFormat: 'Y-m-d'
                    })]
                }, {
                    columnWidth: .4,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextField({
                        fieldLabel: '梯队',
                        name: 'EchelonNumber',
                        anchor: '80%',
                        width: 80,
                        allowBlank: false,
                        blankText: " 梯队数量不能为空"
                    })]
                }, {
                    columnWidth: .6,
                    border: false,
                    layout: 'form',
                    items: [new FantastPlatform.UI.DateTimeField({
                        fieldLabel: '结束时间',
                        allowBlank: false,
                        name: 'EndTime',
                        timeFormat: 'H:i',
                        anchor: '80%',
                        width: 205,
                        dateFormat: 'Y-m-d'
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextArea({
                        fieldLabel: '任务',
                        name: 'Details',
                        height: 100,
                        readOnly: true,
                        anchor: '90%'
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextArea({
                        fieldLabel: '装备',
                        name: 'Equip',
                        readOnly: true,
                        height: 50,
                        anchor: '90%'
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextArea({
                        fieldLabel: '要求',
                        name: 'Require',
                        readOnly: true,
                        height: 50,
                        anchor: '90%'
                    })]
                }, {
                    columnWidth: 1,
                    border: false,
                    layout: 'form',
                    items: [new Ext.form.TextArea({
                        fieldLabel: '执行情况说明',
                        name: 'Description',
                        height: 50,
                        anchor: '90%'
                    })]
                }]
    }];

    FantastPlatform.UI.ElementImplementForm.superclass.constructor.call(this, {
        bodyStyle: 'padding:5px',
        collapsible: true,
        labelAlign: 'right',
        autoScroll: true,
        border: false
    });
};

Ext.extend(FantastPlatform.UI.ElementImplementForm, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.ElementImplementForm.superclass.onRender.call(this, ct, position);
        if (this.Id && this.Id != 0) {
            this.add(new Ext.form.Hidden({ name: 'Id', value: this.Id }));
            var Form = this.form;
            this.form.load({
                url: '../Service/FlowElementViewService.aspx?Action=GetElementImplement',
                params: { id: this.Id },
                waitMsg: '正在读取数据...',
                waitTitle: '请稍后...',
                failure: function (form, action) {
                    if (action.failureType != 'client') {
                        showErrorMessage('操作失败', action.result.message, '');
                    }
                },
                success: function (form, action) {
                }
            });
        }
    }
});

